package com.shenma2009.controller;

import com.shenma2009.domain.ResultResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.*;

/**
 * @author 军哥
 * @version 1.0
 * @description: KafkaController
 * @date 2023/5/22 15:02
 */

@RestController
@Slf4j
@RequestMapping(value = "/kafka")
public class KafkaController {

    @Autowired
    private KafkaTemplate<String, Object> kafkaTemplate;

    @GetMapping(value = "/send/{message}")
    public ResultResponse sendMessage(@PathVariable("message") String message) {

        kafkaTemplate.send("mytest", message);
        log.info(message);

        return ResultResponse.SUCCESS(message);
    }
}
